package com.yunfeisoft.business.model;

import com.yunfeisoft.base.model.WorkflowInstance;
import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;
import com.yunfeisoft.common.utils.DateUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: AskLeaveApproval
 * Description: 请假审批表
 *
 * @Author: Jackie liu
 * Date: 2020-05-14
 */
@Entity
@Table(name = "TT_ASK_LEAVE_APPROVAL")
public class AskLeaveApproval extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 流程定义id
     */
    @Column
    private String workflowDefineId;

    /**
     * 请假天数
     */
    @Column
    private Integer day;

    /**
     * 请假类别(1事假、2病假、3婚假、4产假、5陪产假、6哺乳假、7工伤假、8丧假、9年休假)
     */
    @Column
    private Integer type;

    /**
     * 开始时间
     */
    @Column
    private Date beginDate;

    /**
     * 结束时间
     */
    @Column
    private Date endDate;

    /**
     * 请假原因
     */
    @Column
    private String reason;

    /**
     * 工作交接情况
     */
    @Column
    private String handover;

    /**
     * 备注
     */
    @Column
    private String remark;

    @TransientField
    private Integer validStatus;
    @TransientField
    private String createName;
    //下一节点处理人
    private String nextStepUserId;

    public String getTypeStr() {
        return AskLeaveTypeEnum.valueOf(type);
    }

    public String getBeginDateStr() {
        if (beginDate != null) {
            return DateUtils.dateTimeToString(beginDate);
        }
        return null;
    }

    public String getEndDateStr() {
        if (endDate != null) {
            return DateUtils.dateTimeToString(endDate);
        }
        return null;
    }

    public String getValidStatusStr() {
        return WorkflowInstance.WorkflowInstanceStatusEnum.valueOf(validStatus);
    }

    public String getWorkflowDefineId() {
        return workflowDefineId;
    }

    public void setWorkflowDefineId(String workflowDefineId) {
        this.workflowDefineId = workflowDefineId;
    }

    public Integer getDay() {
        return day;
    }

    public void setDay(Integer day) {
        this.day = day;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getHandover() {
        return handover;
    }

    public void setHandover(String handover) {
        this.handover = handover;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getValidStatus() {
        return validStatus;
    }

    public void setValidStatus(Integer validStatus) {
        this.validStatus = validStatus;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public String getNextStepUserId() {
        return nextStepUserId;
    }

    public void setNextStepUserId(String nextStepUserId) {
        this.nextStepUserId = nextStepUserId;
    }

    /**
     * 请假类别(1事假、2病假、3婚假、4产假、5陪产假、6哺乳假、7工伤假、8丧假、9年休假)
     */
    public enum AskLeaveTypeEnum {

        COMPASSIONATE_LEAVE(1, "事假"),
        SICK_LEAVE(2, "病假"),
        MARRIAGE_HOLIDAY(3, "婚假"),
        MATERNITY_LEAVE(4, "产假"),
        PATERNITY_LEAVE(5, "陪产假"),
        LACTATION_LEAVE(6, "哺乳假"),
        INJURY_LEAVE(7, "工伤假"),
        BEREAVEMENT_LEAVE(8, "丧假"),
        ANNUAL_LEAVE(9, "年假");

        private int value;
        private String label;

        private AskLeaveTypeEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (AskLeaveTypeEnum loop : AskLeaveTypeEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }
    }
}